package com.gy.edu.mine;

import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.gy.edu.R;
import com.gy.edu.base.BaseFragment;
import com.gy.edu.util.AnimUtil;
import com.gy.edu.util.SharedPrefUtil;

/**
 * 作者：gy on 16/12/21
 * 说明：
 */
public class MineHomeFragment extends BaseFragment {

    private LinearLayout llInfo,llUsers,llMessage,llComment,llAsk,llAttention,llChange,llSet;
    private TextView tvLogout;

    @Override
    protected View setView(LayoutInflater inflater) {
        View view = inflater.inflate(R.layout.fragment_mine_home, null);
        _baseBack.setVisibility(View.INVISIBLE);
        setTitleMsg("我的");
        return view;
    }

    @Override
    protected void initView() {
        llInfo = (LinearLayout) _rootView.findViewById(R.id.mine_ll_info);
        llUsers = (LinearLayout) _rootView.findViewById(R.id.mine_ll_users);
        llMessage = (LinearLayout) _rootView.findViewById(R.id.mine_ll_message);
        llComment = (LinearLayout) _rootView.findViewById(R.id.mine_ll_comment);
        llAsk = (LinearLayout) _rootView.findViewById(R.id.mine_ll_ask);
        llAttention = (LinearLayout) _rootView.findViewById(R.id.mine_ll_attention);
        llChange = (LinearLayout) _rootView.findViewById(R.id.mine_ll_change);
        llSet = (LinearLayout) _rootView.findViewById(R.id.mine_ll_set);
        tvLogout = (TextView) _rootView.findViewById(R.id.mine_tv_logout);
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void setListener() {
        super.setListener();
        llInfo.setOnClickListener(this);
        llUsers.setOnClickListener(this);
        llMessage.setOnClickListener(this);
        llComment.setOnClickListener(this);
        llAsk.setOnClickListener(this);
        llAttention.setOnClickListener(this);
        llChange.setOnClickListener(this);
        llSet.setOnClickListener(this);
        tvLogout.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        super.onClick(v);
        Intent intent = null;
        switch (v.getId()){
            case R.id.mine_ll_info:
                intent = new Intent(mContext,UserInfoActivity.class);
                break;
            case R.id.mine_ll_message:
                intent = new Intent(mContext,MyMessageActivity.class);
                break;
            case R.id.mine_ll_users:
                intent = new Intent(mContext,MyFriendActivity.class);
                break;
            case R.id.mine_ll_comment:
                intent = new Intent(mContext,MyCommentActivity.class);
                break;
            case R.id.mine_ll_ask:
                intent = new Intent(mContext,MyAskActivity.class);
                break;
            case R.id.mine_ll_attention:
                intent = new Intent(mContext,MyAttentionActivity.class);
                break;
            case R.id.mine_ll_change:
                intent = new Intent(mContext,ChangePwdActivity.class);
                break;
            case R.id.mine_ll_set:
                intent = new Intent(mContext,SettingActivity.class);
                break;
            case R.id.mine_tv_logout:
                SharedPrefUtil.put("login",false);
                intent = new Intent(mContext,LoginActivity.class);
                break;
        }
        startActivity(intent);
        AnimUtil.pushLeftInAndOut(getActivity());
        if(v.getId() == R.id.mine_tv_logout){
            getActivity().finish();
        }
    }
}
